<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta content="text/html;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
	<meta http-equiv ="Pragma" content = "no-cache"/>
	<meta http-equiv="Cache-Control" content="no cache" />
	<meta http-equiv="Expires" content="0" />
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
	<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
	<meta name="apple-mobile-web-app-capable" content="yes"/>
	<meta name="format-detection" content="telephone=no"/>
	<script src="https://cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
	<link href="https://cdn.bootcss.com/pace/1.0.2/themes/pink/pace-theme-flash.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="/static/fsLayui-1.8.2/plugins/layui/css/layui.css" media="all"/>
	<link rel="stylesheet" type="text/css" href="/static/fsLayui-1.8.2/css/fs.css" media="all"/>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/layui/layui.js"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/frame/js/fsDict.js?v=1.5.0"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/frame/js/fs.js?v=1.5.0"></script>
	<script type="text/javascript" src="/static/fsLayui-1.8.2/plugins/frame/js/frame.js?v=1.5.0"></script>
</head>
<body>
	<div class="layui-fluid">
	<fieldset class="layui-elem-field layui-field-title">
	  <legend>博主信息</legend>
	</fieldset>
	<form class="layui-form" id="edit_form" isLoad="1" loadUrl="/admin/blogger/find">
	  <input type="hidden" name="bloggerId" />
	  <input type="hidden" id="headPortrait" name="headPortrait"/>
	  <div class="layui-form-item" style="width: 800px;">
	    <label class="layui-form-label">昵称</label>
	    <div class="layui-input-block">
	      <input type="text" name="nickName" required="" lay-verType="tips" lay-verify="required" placeholder="请输入文章标题" autocomplete="off" class="layui-input"/>
	    </div>
	  </div>
	  <div class="layui-form-item" style="width: 800px;">
	    <label class="layui-form-label">地址</label>
	    <div class="layui-input-block">
	      <input type="text" name="site" required="" lay-verType="tips" lay-verify="required" placeholder="请输入文章作者" autocomplete="off" class="layui-input"/>
	    </div>
	  </div>
	  
	  <div class="layui-form-item">
	    <label class="layui-form-label">头像</label>
	  <div class="layui-upload">
		  <button type="button" class="layui-btn" id="test1">上传图片</button>
		  <div class="layui-upload-list">
		    <p id="demoText"></p>
		  </div>
		</div>
		</div>
		
		<div class="layui-form-item">
	    <label class="layui-form-label"></label>
	    <div class="layui-input-block">
	      <img class="layui-upload-img layui-circle" id="demo1" style="height: 250px;" />
	    </div>
	  </div>
	  
	  <div class="layui-form-item" style="width: 800px;">
	    <label class="layui-form-label">座右铭</label>
	    <div class="layui-input-block">
	      <input type="text" name="motto" required="" lay-verType="tips" lay-verify="required" placeholder="请输入座右铭" autocomplete="off" class="layui-input"/>
	    </div>
	  </div>
	  <div class="layui-form-item" style="width: 800px;">
	    <label class="layui-form-label">个性签名</label>
	    <div class="layui-input-block">
	      <input type="text" name="signature" required="" lay-verType="tips" lay-verify="required" placeholder="请输入个性签名" autocomplete="off" class="layui-input"/>
	    </div>
	  </div>
	  <hr/>
	  <div class="layui-form-item" style="margin-left: 100px;">
     	 <button class="layui-btn" lay-submit="" lay-filter="edit" url="/admin/blogger/save">保存</button>
    </div>
</form>

	</div>
	
<script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
  //普通图片上传
  var uploadInst = upload.render({
    elem: '#test1'
    ,url: '/upload'
    ,before: function(obj){ //上传图片之前的图片预览
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.code > 0){
        return layer.msg('上传失败');
      }
      //将上传失败的图片名称放入id为headPortrait的input里面
      $('#headPortrait').val(res.data.filePath); //图片链接（base64）
      //上传成功
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  });
});

$(window).load(function(){
	setTimeout(images, 200);
});
function images(){
	var str=$('#headPortrait').val();
	 $("#demo1").attr("src","/static/images/"+str);
}
</script>
</body>
</html>
